package com.appspot.modutajataja;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;

public class EventActivity extends Activity {
	final int htmlWidth = 900;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_event);
		
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

		double width = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
		int scalePecent = (int)(width/htmlWidth*90);
		System.out.println(scalePecent);

		WebView webViewInfo = (WebView) findViewById(R.id.webView_info);
		webViewInfo.getSettings().setRenderPriority(RenderPriority.HIGH);
		webViewInfo.getSettings().setJavaScriptEnabled(true);
		webViewInfo.loadUrl(C.tajaAppNewsURL);

		WebView webViewEvent = (WebView) findViewById(R.id.webView_event);
		webViewEvent.getSettings().setJavaScriptEnabled(true);
		webViewEvent.getSettings().setRenderPriority(RenderPriority.HIGH);
		webViewEvent.getSettings().setLoadWithOverviewMode(true);
		webViewEvent.setInitialScale(scalePecent);
		webViewEvent.setVerticalScrollBarEnabled(false);
		webViewEvent.setHorizontalScrollBarEnabled(false);
		webViewEvent.loadUrl(C.tajaAppEventURL);
	}
	public void HomebackOnClick(View v) {
		startActivity(new Intent(EventActivity.this, MainActivity.class));
		EventActivity.this.finish();
	}
	
	@Override
	public void onBackPressed() {

		AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
		alt_bld.setMessage("게임을 종료 하시겠습니까?")
				.setCancelable(false)
				.setPositiveButton("Yes",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								finish();
							}
						})
				.setNegativeButton("No", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int id) {
						dialog.cancel();
					}
				});
		AlertDialog alert = alt_bld.create();
		alert.setTitle("게임 종료");
		alert.setIcon(R.drawable.ic_launcher);
		alert.show();
	}
};